module Main where

gcd' :: Integral a => a -> a -> a
gcd' n m = if r == 0 then s else gcd' s r
    where b = if n > m then n else m
          s = if n > m then m else n
          q = quot b s
          r = mod b s

-- This part is related to the Input/Output and can be used as it is
-- Do not modify it
main = do
  input <- getLine
  print . uncurry gcd' . listToTuple . convertToInt . words $ input
 where
  listToTuple (x:xs:_) = (x,xs)
  convertToInt = map (read :: String -> Int)
